home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 11
/
CU Amiga Magazine's Super CD-ROM 11 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-06].iso
/
cucd
/
graphics
/
dsscripts
/
pie.dsrx
< prev
next >
Wrap
Text File
|
1997-03-08
|
4KB
|
157 lines
/* Allow commands to return results */
options results
/* On error, goto ERROR:. Comment out this line if you wish to */
/* perform your own error checking. */
signal on error
'PROJECT_LOCK'
/* BEGIN PROGRAM *************************************************/
/* +++++++++++++++++++++++++++++++++++ */
/* + + */
/* + Pie chart plotting ARexx script + */
/* + + */
/* + Written by Andrew Elia + */
/* + + */
/* +++++++++++++++++++++++++++++++++++ */
PIESIZE = 10 /* */
CENX = 10 /* */
CENY = 10 /* */
UNIT = "cm" /* Sets the measurement units */
GSIZE = 5 /* Sets the number of values/slices in the pie */
/* Just creates some data to demonstrate the effect */
Do N=0 To GSIZE-1
X=(N + 1) * 4
GRAPH.N = X
End N
/* Finds the total size of the data used, so that each slice can */
/* be scaled accordingly */
PIEMAX=0
Do N = 0 To GSIZE-1
PIEMAX = PIEMAX + GRAPH.N
End N
/* Opens the rexxmathlib.library so that trigonometric functions */
/* are available, and sets up a variable which is used to convert */
/* Degrees to Radians as the library only works in Radians */
call addlib("rexxmathlib.library", 0, -30, 0)
CONVERT=PI(0)/180
PIEANG = 0
Do N = 0 To GSIZE-1
/* Works out the size/angle of a particular slice */
SLICE = GRAPH.N / PIEMAX
SLICEANG = 360 * SLICE
/* Calculates the positions of each of the two edges of the slice */
X1 = (Sin(CONVERT * PIEANG) * PIESIZE) + CENX
Y1 = (Cos(CONVERT * PIEANG) * PIESIZE) + CENY
X2 = (Sin(CONVERT * (PIEANG + SLICEANG)) * PIESIZE) + CENX
Y2 = (Cos(CONVERT * (PIEANG + SLICEANG)) * PIESIZE) + CENY
/* Now the naff bit. This has a stab at trying to make the outer */
/* edges of the slices look like an arc. Doesn't quite look the */
/* part, though. Let me know if you find a more appropriate way */
/* of dealing with this. */
LB = SLICE * PIESIZE
L1 = LB + Sqr(Pow(Abs(X1-CENX),2) + Pow(Abs(Y1-CENY),2))
L2 = LB + Sqr(Pow(Abs(X2-CENX),2) + Pow(Abs(Y2-CENY),2))
B1 = (Sin(CONVERT * PIEANG) * L1) + CENX
B2 = (Cos(CONVERT * PIEANG) * L1) + CENY
B3 = (Sin(CONVERT * (PIEANG + SLICEANG)) * L2) + CENX
B4 = (Cos(CONVERT * (PIEANG + SLICEANG)) * L2) + CENY
/* This actuall draws the slice */
"CREATE_BEZIER CLOSED "||CENX||UNIT||" "||CENY||UNIT||" L "||X1||UNIT||" "||Y1||UNIT||" B "||B1||UNIT||" "||B2||UNIT||" "||B3||UNIT||" "||B4||UNIT||" "||X2||UNIT||" "||Y2||UNIT
PIEANG = PIEANG + SLICEANG
End N
/* For the time being, this bit has been added to provide a reference */
/* for the user to correct the crap bits on the pie slices. */
"CREATE_ELLIPSE "||CENX||UNIT||" "||CENY||UNIT||" "||PIESIZE||UNIT||" "||PIESIZE||UNIT
/* END PROGRAM ***************************************************/
'PROJECT_UNLOCK'
exit
/* On ERROR */
ERROR:
'PROJECT_UNLOCK'
/* If we get here, either an error occurred with the command's */
/* execution or there was an error with the command itself. */
/* In the former case, rc2 contains the error message and in */
/* the latter, rc2 contains an error number. SIGL contains */
/* the line number of the command which caused the jump */
/* to ERROR: */
if datatype(rc2,'NUMERIC') == 1 then do
/* See if we can describe the error with a string */
select
when rc2 == 103 then
err_string = "ERROR 103, "||,
"out of memory at line "||SIGL
when rc2 == 114 then
err_string = "ERROR 114, "||,
"bad command template at line "||SIGL
when rc2 == 115 then
err_string = "ERROR 115, "||,
"bad number for /N argument at line "||SIGL
when rc2 == 116 then
err_string = "ERROR 116, "||,
"required argument missing at line "||SIGL
when rc2 == 117 then
err_string = "ERROR 117, "||,
"value after keywork missing at line "||SIGL
when rc2 == 118 then
err_string = "ERROR 118, "||,
"wrong number of arguments at line "||SIGL
when rc2 == 119 then
err_string = "ERROR 119, "||,
"unmatched quotes at line "||SIGL
when rc2 == 120 then
err_string = "ERROR 120, "||,
"line too long at line "||SIGL
when rc2 == 236 then
err_string = "ERROR 236, "||,
"unknown command at line "||SIGL
otherwise
err_string = "ERROR "||rc2||", at line "||SIGL
end
end
else if rc2 == 'RC2' then do
err_string = "ERROR in command at line "||SIGL
end
else do
err_string = rc2||", line "||SIGL
end
req_message TEXT '"'err_string'"'
exit